home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 26.zip
/
BS1 part 26
/
C for beginners.adf
/
source
/
math1.c
< prev
next >
Wrap
C/C++ Source or Header
|
1978-01-17
|
898b
|
82 lines
/* math1.c 4.5.3 */
void main()
{
int number1, number2, result, operator, error;
printf("Please input two numbers!\n");
scanf("%d%d", &number1, &number2);
printf("And now the code for the operation!\n");
printf("1=Add, 2=Subtract, 3=Multiply, 4=Divide\n");
scanf("%d", &operator);
error = 1;
if(operator == 1) /* Addition */
{
result = number1 + number2;
error = 0;
}
if(operator == 2) /* Subtraction */
{
result = number1 - number2;
error = 0;
}
if(operator == 3) /* Multiplication */
{
result = number1 * number2;
error = 0;
}
if(operator == 4) /* Division */
{
result = number1 / number2;
error = 0;
}
if(error == 1) /* None of the above conditions */
printf("Wrong Code! Input only numbers 1 - 4!\n");
else
printf("The result is %d\n", result);
}